package com.seuic.hnjiningposapp.hnapps.util;

import com.blankj.utilcode.util.SPStaticUtils;
import com.socks.library.KLog;

/**
 * 交易次数 交易金额比较
 */
public class DealMoneyAndNumComparisonUtils {
    //取款
    public static final String WITHDRAWAL = "withdrawal";
    //汇款 ==存款
    public static final String REMITTANCE = "remittance";
    //转账
    public static final String TRANSFERACCOUNTS = "transferaccounts";

    public static void comparison(String type, String thiscount, String thismoney, ComparisonCallBack comparisonCallBack) {
        boolean next = true;

        String msg = "没有超出今日操作次数,金额";
        //总交易次数
        Double Allcount = 0.00;
        //总交易金额
        Double Allmoney = 0.00;

        KLog.e(thiscount);
        KLog.e(thismoney);
        if (type.equals(WITHDRAWAL)) {

            Allcount = Double.parseDouble(SPStaticUtils.getString("TRADE_DRAWALCOUNT_LIMIT"));
            Allmoney = Double.parseDouble(SPStaticUtils.getString("TRADE_AMOUNT_LIMIT"));

        } else if (type.equals(REMITTANCE)) {
            Allcount = Double.parseDouble(SPStaticUtils.getString("DEPOSIT_COUNT_LIMIT"));
            Allmoney = Double.parseDouble(SPStaticUtils.getString("DEPOSIT_AMOUNT_LIMIT"));
        } else if (type.equals(TRANSFERACCOUNTS)) {
            Allcount = Double.parseDouble(SPStaticUtils.getString("TRADE_COUNT_LIMIT"));
            Allmoney = Double.parseDouble(SPStaticUtils.getString("TRADE_TRANSFER_LIMIT"));
        }

        KLog.e(Allcount + "cccccc" + thiscount);
        KLog.e(Allmoney + "cccccc" + thismoney);
        if (!(Allcount > Double.parseDouble(thiscount))) {
            msg = "超出今日操作次数";
            next = false;
        }
        if (!(Allmoney > Double.parseDouble(thismoney))) {
            msg = "超出今日操作金额";
            next = false;
        }
        comparisonCallBack.callBack(next, msg);
    }

    public interface ComparisonCallBack {
        void callBack(boolean next, String msg);
    }
}
